# -*- coding: utf-8 -*-
from django.contrib.sitemaps import GenericSitemap as DjangoGenericSitemap
from django.contrib.sitemaps import Sitemap as DjangoSitemap

from Scope.models import Noticia


def GoogleNews(googlenews=False):
    article = Noticia.objects.filter(publicar__icontains=1, nomeCategoria__id=1)
    if googlenews:
        article = article[:1000]
    return {
        'queryset': article,
        'date_field': 'datacriacao',
    }

def Sitemap(googlenews=False):
    article = Noticia.objects.exclude(nomeCategoria__id=1).filter(publicar__icontains=1)
    if googlenews:
        article = article[:1000]
    return {
        'queryset': article,
        'date_field': 'datacriacao',
    }

class BaseSitemap(DjangoSitemap):
    priority = 0.6

    def items(self):
        return Noticia.objects.all()

    def lastmod(self, obj):
        return obj.date_available


class GenericSitemap(DjangoGenericSitemap):
    limit = 1000
    priority = 0.6